/**
 * 
 */
package fecat.entities.quote;

import java.util.HashMap;
import java.util.Map;

import fecat.entities.QuoteModel;
import fecat.services.log.LoggingService;

/**
 * @author ibm
 *
 */
public class QuoteQueue {
	private Map<String,QuoteModel> quoteMap=new HashMap<String,QuoteModel>();
	public synchronized void addAlls(QuoteModel[] qms){
		for(QuoteModel qm:qms){
			quoteMap.put(qm.getName(),qm);
		}
		notifyAll();
	}
	public synchronized QuoteModel[] popAlls(){
		QuoteModel[] qms=null;
		if(quoteMap.size()==0){
			try{
				wait();
			}
			catch(Exception ex){
				LoggingService.error(ex);
			}
		}
		if(quoteMap.size()!=0){
			qms=quoteMap.values().toArray(new QuoteModel[0]);
			quoteMap.clear();
		}
		return qms;
	}
	public void clear(){
		quoteMap.clear();
	}
}
